package com.bootdo.provider.service.impl;

import com.bootdo.provider.domain.dto.GoodsExcel;
import com.bootdo.stock.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.bootdo.provider.dao.GoodsInfoDao;
import com.bootdo.provider.domain.GoodsInfoDO;
import com.bootdo.provider.service.GoodsInfoService;
import org.springframework.transaction.annotation.Transactional;


@Service
public class GoodsInfoServiceImpl implements GoodsInfoService {
	@Autowired
	private GoodsInfoDao goodsInfoDao;
	@Autowired
	private StockService stockService;
	
	@Override
	public GoodsInfoDO get(Long goodsId){
		return goodsInfoDao.get(goodsId);
	}
	
	@Override
	public List<GoodsInfoDO> list(Map<String, Object> map){
		return goodsInfoDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return goodsInfoDao.count(map);
	}
	
	@Override
	public int save(GoodsInfoDO goodsInfo){
		int i=goodsInfoDao.save(goodsInfo);
		stockService.save(goodsInfo.getGoodsId());
		return i;
	}
	
	@Override
	public int update(GoodsInfoDO goodsInfo){
		return goodsInfoDao.update(goodsInfo);
	}
	
	@Override
	public int remove(Long goodsId){
		return goodsInfoDao.remove(goodsId);
	}
	
	@Override
	public int batchRemove(Long[] goodsIds){
		return goodsInfoDao.batchRemove(goodsIds);
	}


	@Override
	public GoodsInfoDO getGoodsBySku(Map<String,Object> map){
		return goodsInfoDao.getGoodsBySku(map);
	}

	@Override
	public int saveExcel(GoodsExcel goodsInfo) {
		int i=goodsInfoDao.saveExcel(goodsInfo);
		stockService.save(goodsInfo.getGoodsId());
		return i;
	}

}
